'''
Created on Jul 2, 2011

@author: Nam Khanh
'''

class DepNode:
    """    
    """
    def __init__(self, idx, form, pos, head_idx=None, target_head = None):
        """        
        """
        self.idx = idx
        self.form = form
        self.pos = pos
        self.head_idx = head_idx
        self.target_head = target_head
    
    def __unicode__(self):
        """
        """
        return self.idx, self.form, self.pos, self.head_idx, self.target_head

class DepTree:
    """
    List of DepNode
    """
    def __init__(self, node_list):
        """
        """
        self.node_list = node_list
    
    def __getitem__(self, index):
        """
        """
        return self.node_list[index]

    def get_idx(self,index):
        """
        """
        return [idx for idx in [node.idx for node in self.node_list]][index]             
    
    def get_form(self, index):
        """
        """
        return [form for form in [node.form for node in self.node_list]][index]      

    def get_pos(self, index):
        """
        """
        return [pos for pos in [node.pos for node in self.node_list]][index]        

    def get_head_idx(self, index):
        """
        """
        return [head_idx for head_idx in [node.head_idx for node in self.node_list]][index]      

    def get_target_head(self, index):
        """
        """
        return [target_head for target_head in [node.target_head for node in self.node_list]][index]        

    def add(self, node):
        """
        """
        self.node_list.append(node)        
        
    def __len__(self):
        """
        """
        return len(self.node_list)         